//
//  RootViewController.m
//  UI_面包旅行
//
//  Created by 谷萌雨 on 15/12/21.
//  Copyright © 2015年 谷萌雨. All rights reserved.
//

#import "RootViewController.h"
#import "MyTableViewCell.h"
#import "WheelImage.h"
#import "MHNetWorkTask.h"
#import "PicModel.h"

@interface RootViewController ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, retain)UITableView *myTableView;
@property(nonatomic, retain)NSMutableArray *allArray;


@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.myTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] bounds] style:UITableViewStylePlain];
    
    [self.view addSubview:self.myTableView];
    
    self.myTableView.backgroundColor = [UIColor orangeColor];
    self.myTableView.dataSource = self;
    self.myTableView.delegate = self;
    

    [self.myTableView registerClass:[MyTableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.myTableView registerClass:[MyTableViewCell class] forCellReuseIdentifier:@"cell2"];
    
    UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 200)];
    
    aView.backgroundColor = [UIColor purpleColor];
    
    WheelImage *myWheelImage = [[WheelImage alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 200) withImageArray:nil withNIdArray:nil];
    
    self.myTableView.tableHeaderView = myWheelImage;
    
//    [self getDataSource];
    
    

    
}


-(void)getDataSource{
    
    NSString *url = @"http://api.breadtrip.com/v2/index/?lat=38.88263963415547&lng=121.5394687921301&sign=2bffaf369d5f6b4a435b94dbbbd5bc52";
//    [MHNetWorkTask getWithURL:url withParameter:nil withHttpHeader:nil withResponseType:ResponseTypeJSON withSuccess:^(id result) {
//        
//        
//        
//        self.allArray = [NSMutableArray new];
//        
//        NSDictionary *dic = result[@"data"];
//        
//        NSArray *array = dic[@"elements"];
//
//        for (NSDictionary *dic2 in array) {
//            NSArray *array2 = dic2[@"data"];
//            
//            for (NSDictionary *dic3 in array2) {
//                
////                for (NSArray *array3 in array2) {
////                for (NSDictionary *dic3 in array3) {
//
//                PicModel *picModel = [[PicModel alloc] init];
//                
//                [picModel setValuesForKeysWithDictionary:dic3];
//                
//                [self.allArray addObject:picModel];
//                
//            }
//        }
//        
//
//        
//        
//        
//    } withFail:^(NSError *error) {
//        
//        
//    }];
    
    
    
    
    
    
    
    
}



- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 2;
    
    
}

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    if (section == 0) {
        return 2;
        
        
    }
   
        return 30;
    
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        return 240;
    }
    
    return 150;
    
    
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    if(indexPath.section == 0){
    
    MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    return cell;
    
    }else{
        MyTableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"cell2"];
        
        return cell2;
        
        
        
    }
    
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
